package com.chalmers.foa.gamemodel.gameobjects;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Bitmap;
import android.graphics.Point;

public abstract class GameObjectBitmapAdapter extends GameObjectAdapter {
	
	protected Bitmap bitmap;
	private List<Integer> colorList;
	
	public GameObjectBitmapAdapter(Bitmap _bitmap,Point position,int layer,int _boundID, boolean solid,
			boolean affectedByGravity, boolean affectedByTilting, boolean hazardous){
		super(position,layer,_boundID,solid,affectedByGravity,affectedByTilting,hazardous);
		setBitmap(_bitmap);
	}
	public GameObjectBitmapAdapter(Bitmap _bitmap,Point _position,int layer,int _boundID){
		this(_bitmap,_position,layer,_boundID,false, false, false, false);
	}
	
	public Bitmap getBitmap(){
		return bitmap;
	}
	
	public List<Integer> getColors() {
		if(colorList == null) {
			colorList = new ArrayList<Integer>();
			for(int y = 0; y < bitmap.getHeight(); y++)
				for(int x = 0; x < bitmap.getWidth(); x++) {
					if(bitmap.getPixel(x,y) != 0)
						colorList.add(Integer.valueOf(bitmap.getPixel(x,y)));
				}
		}
		return colorList;
	}
	
	private void setBitmap(Bitmap _bitmap){
		bitmap = _bitmap;
		this.width=bitmap.getWidth();
		this.height=bitmap.getHeight();
	}
	
}
